package com.example.teachingevaluationsystem.config.auth;

import com.example.teachingevaluationsystem.entity.User;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

@AllArgsConstructor
@Data
public class UserAuthInfoDetails implements UserDetails {
  // 用户信息
  private User user;
  // 角色信息
  private List<GrantedAuthority> roleKeys;

  @Override
  public Collection<? extends GrantedAuthority> getAuthorities() {
    return roleKeys;
  }

  @Override
  public String getPassword() {
    return user.getPassword();
  }

  public Long getUserId() {
    return user.getId();
  }

  @Override
  public String getUsername() {
    return user.getUsername();
  }

  @Override
  public boolean isAccountNonExpired() {
    return false;
  }

  @Override
  public boolean isAccountNonLocked() {
    return false;
  }

  @Override
  public boolean isCredentialsNonExpired() {
    return false;
  }

  @Override
  public boolean isEnabled() {
    return false;
  }
}
